package vsy.buzzwordbingo.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class LoginController {

	//TODO Prevent a logged in user from logging in again before he has logged out
	
	@RequestMapping("/login")
	public ModelAndView login(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		request.setAttribute("sessionId", request.getSession().getId());
		return new ModelAndView("login");
	}

	@RequestMapping("/login/error")
	public ModelAndView loginError(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		request.setAttribute("sessionId", request.getSession().getId());
		request.setAttribute("error", true);
		return new ModelAndView("login");
	}
}
